<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <%@ taglib prefix="s" uri="http://www.springframework.org/tags" %>
<!DOCTYPE html>
<html>
<head>
<script src="${pageContext.request.contextPath}/js/jquery.min.js"></script>
<meta charset="UTF-8">
<title><s:message code="EMPLOYEE.EDIT"></s:message></title>
</head>
<body>
<form action="#">
<s:message code="EMPLOYEE.LASTNAME"></s:message>：<input type="text" name="lastName" value=""/><br>
<s:message code="EMPLOYEE.EMAIL"></s:message>：<input type="text" name="email" value=""/><br>
<s:message code="EMPLOYEE.GENDER"></s:message>：男<input type="radio" name="gender" value="男"/>  女<input type="radio" name="gender" value="女"/><br>
<input type="submit" id="submit" value="<s:message code='SYS.SUBMIT'></s:message>">
</form>
</body>
<script>
$(function(){
    var gender = '${employee.gender}';
    $("#submit").click(function(){
    	 var array =  $("form").serializeArray();
    	var json = {};
     	for(var i=0;i<array.length;i++){
     		json[array[i].name] = array[i].value;
     	}
     	json = JSON.stringify(json);
    	  $.ajax({
    	        type: 'post',
    	        url: '${pageContext.request.contextPath }/emp/save',
    	        data: json,//必须是字符串
    	        contentType:"application/json;charset=utf-8",
    	        success: function(data) {
    	        	if(data.code == 200){
    	        		window.location.href="${pageContext.request.contextPath }/emp/list";
    	        		return true;
    	        	}else{
    	        		alert(data.msg);
    	        	}
    	        }
    	    }); 
    	  return false;
    })
   

})
</script>
</html>